package dy.app.base;

import dy.app.cache.LocalCache;
import dy.app.component.AuthComponent;
import dy.app.constant.GlobalConstant;
import dy.app.dto.SlUserCacheDto;
import dy.app.dto.SysCacheUserDto;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * 基础服务类 其他微服务中的serviceImpl 继承此类 快速获取相关信息
 * Author: cKnight
 * Date: 2024/6/11
 */
@Component
public class BaseService {
    @Resource
    private AuthComponent authComponent;

    /**
     * 获取后管用户信息
     * @return
     */
    public SysCacheUserDto getAdminUserInfo(){
        return authComponent.getAdminUserInfo();
    }

    /**
     * 获取app用户信息
     * @return
     */
    public SlUserCacheDto getAppUserInfo(){
        return (SlUserCacheDto) LocalCache.objectFactoryHashMap.get(GlobalConstant.APP_USER_PROCESS_KEY).getObject();
    }
}
